package com.heima.comment.controller;

import com.heima.comment.dto.CommentDto;
import com.heima.comment.dto.CommentLikeDto;
import com.heima.comment.dto.CommentSaveDto;
import com.heima.comment.service.ICommentService;
import com.heima.common.dto.ResponseResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {

    @Autowired
    private ICommentService iCommentService;

    @PostMapping("/save")
    @ApiOperation(value = "保存评论", notes = "author:mcm")
    public ResponseResult save(@RequestBody CommentSaveDto dto){
        return iCommentService.save(dto);
    }

    @PostMapping("/like")
    @ApiOperation(value = "点赞评论", notes = "author:mcm")
    public ResponseResult likeComment(@RequestBody CommentLikeDto dto){
        return iCommentService.likeComment(dto);
    }

    @PostMapping("/load")
    @ApiOperation(value = "加载评论", notes = "author:mcm")
    public ResponseResult loadComment(@RequestBody CommentDto dto){
        return iCommentService.loadComment(dto);
    }
}
